package com.hsy.linemoney.modules.my.mydeals;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.hsy.linemoney.apiservice.Callback;
import com.hsy.linemoney.apiservice.MyDealService;
import com.hsy.linemoney.utils.CommonUtils;

/**
 * 部分完成
 */
public class PartDealedFragment extends MyDealFragment {
    private boolean isinited = false;

    private MyDealService service = new MyDealService();

    @Override
    protected void initView(View view, Bundle bundle) {
        super.initView(view, bundle);
        isinited = true;
    }

    @Override
    protected int getType(int position) {
        return MyDealBean.PART_DEALED;
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        performUserVisibleHint(isVisibleToUser);
    }

    private void performUserVisibleHint(boolean isVisibleToUser) {
        if (isVisibleToUser && isinited) {
            showProgressDialog(getAttchedActivity());
            service.getPartDealedOrder(new Callback<MyDealService.PartDealedOrderResult>() {
                @Override
                public void onSuccess(int what, MyDealService.PartDealedOrderResult result) {
//                adapter.update(result.);
                    hideProgressDialog();
                }

                @Override
                public void onError(int what, int type, String msg, Exception e) {
                    hideProgressDialog();
                }
            }, true);
        }
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
//        for (int i = 0; i < 10; i++) {
//            data.add(new MyDealBean());
//        }
//        adapter.update(data);
        performUserVisibleHint(true);
    }
}
